package com.quktzhuanka.app.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.quktzhuanka.app.R;
import com.quktzhuanka.app.my.MyOrderActivity;
import com.quktzhuanka.app.utils.JifenUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author wim
 */
public class DialogActivity2 extends Activity {
    @BindView(R.id.ss)
    TextView ss;
    @BindView(R.id.txt_tip)
    TextView ss2;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_dialog2);
        getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        ButterKnife.bind(this);
        setFinishOnTouchOutside(true);
        ss.setText(getIntent().getStringExtra("search"));
        if(TextUtils.isDigitsOnly(ss.getText().toString())){
            ss2.setText("您可能复制了订单号，是否前去搜索");
            findViewById(R.id.ll_root).setVisibility(View.GONE);
        }else{
            ss2.setText("您可能复制了商品标题，是否前去搜索");
            findViewById(R.id.ll_root).setVisibility(View.VISIBLE);
            findViewById(R.id.txt_ok).setVisibility(View.GONE);
        }
    }

    @OnClick({R.id.txt_cancle, R.id.txt_ok,R.id.img_t,R.id.img_d,R.id.img_p})
    public void onViewClicked(View view) {
        Intent intent=new Intent(this,SearchResultActivity.class);
        switch (view.getId()) {
            case R.id.txt_cancle:
                finish();
                break;
            case R.id.img_t:    // 淘宝
                JifenUtils.record_num(this,11);
                Bundle bundle = new Bundle();
                bundle.putString("content",ss.getText().toString());
                bundle.putInt("type", 0);//1高级搜索 0 普通搜索
                intent.putExtras(bundle);
                startActivity(intent);
                finish();
                break;
            case R.id.img_d:   // 京东
                JifenUtils.record_num(this,11);
                intent=new Intent(this, JdSearchRestultActivity.class);
                intent.putExtra("key", ss.getText().toString().trim());
                startActivity(intent);
                finish();
                break;
            case R.id.img_p:   // 拼多多
                JifenUtils.record_num(this,11);
                intent=new Intent(this,PddSearchResultActivity.class);
                intent.putExtra("keyword",ss.getText().toString().trim());
                startActivity(intent);
                finish();
                break;
            case R.id.txt_ok:
                if(TextUtils.isDigitsOnly(ss.getText().toString())){
                    startActivity(new Intent(this,MyOrderActivity.class).putExtra("se",ss.getText().toString()));
                    finish();
                }else{
//                    Bundle bundle = new Bundle();
//                    bundle.putString("content",ss.getText().toString());
//                    bundle.putInt("type", 0);//1高级搜索 0 普通搜索
//                    Intent intent=new Intent(this,SearchResultActivity.class);
//                    intent.putExtras(bundle);
//                    startActivity(intent);
//                    finish();
                }
                break;
        }
    }
}
